package com.xpec.c4.game.spinMoneyRecorder.async;

import org.hibernate.Session;

import com.xpec.c4.db.hibernate.manager.HibernateLogManager;
import com.xpec.c4.game.spinMoneyRecorder.db.SpinMoneyRecordLogModel;
import com.xpec.c4.service.module.task.TaskAsyncCommand;

/**
 * 儲存 spin money record 的異步處理
 * 
 * @author 16040
 *
 */
public class SaveSpinMoneyRecordAsync extends TaskAsyncCommand {
	/**
	 * log model
	 */
	private SpinMoneyRecordLogModel model;

	@Override
	public void asyncExecute() throws Exception {
		if (model != null) {
			Session s = HibernateLogManager.txBegin();
			s.saveOrUpdate(model);
			HibernateLogManager.txCommitFailRollbackClearSession();
		}
	}

	@Override
	public void execute() throws Exception {
	}

	public SpinMoneyRecordLogModel getModel() {
		return model;
	}

	public void setModel(SpinMoneyRecordLogModel model) {
		this.model = model;
	}
}
